package com.SuanFa.mati;

//在含有n个元素的A集合中如果有含有m个元素的B集合的个数达到2个
//且在A集合中每个元素只能使用一次，指定的B集合的顺序固定。就输出Yes，否则输出No
import java.util.Scanner;
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int [] A = new int[n];
        for (int i = 0; i < A.length; i++) {
            A[i] = sc.nextInt();
        }
        int [] B = new int[m];
        for (int i = 0; i < B.length; i++) {
            B[i] = sc.nextInt();
        }
        int count = 0;
        if (m > n) {
            System.out.println(0);
        }
        int num = 0;
        int temp = 0;
        while (num<2) {
            count =0;
            for (int i = 0; i < A.length; i++) {
                if (A[i] == B[count]) {
                    A[i] =-1;
                    count++;
                }
                if (count == B.length) {
                    temp++;
                    break;
                }
            }
            num++;
        }
        if (temp == 2) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}

